
var netcore = require('../../../utils/network.js')
var tripleDes = require('../../../utils/CKCrypto.js')
var course = require('../../index/model/CourseIndex.js')

function getGradeList(callBack){
  var param=new Map();
  netcore.requestPost("apiController/getGradeLists.do",param,function(success){
    callBack(success)
  },function(code,errMsg){
    wx.showToast({
      title: errMsg,
      icon:''
    })
  })
}
function getPorjectTypeList(callBack){
  var param = new Map();
  netcore.requestPost("course/getProjectTypeList.do", param, function (success) {
    callBack(success)
  }, function (code, errMsg) {
    wx.showToast({
      title: errMsg,
      icon: ''
    })
  })
}
function getProjectEditionList(callBack){
  var param = new Map();
  netcore.requestPost("course/getProjectEditionList.do", param, function (success) {
    callBack(success)
  }, function (code, errMsg) {
    wx.showToast({
      title: errMsg,
      icon: ''
    })
  })
}
function getCourseList(type,grade,projectType,projectEdition,pageNum,pageCount,callBack){
  course.getCourse(type, grade, "1", projectType, projectEdition, pageNum, pageCount, callBack)
}
function getDetail(courseId,callBack){
  var param = new Map();
  param.set("id", tripleDes.enCode(courseId));
  // param.set("id", courseId);
  console.log(param);
  console.log(courseId);
  netcore.requestPost("course/getCourseDetailsLists.do", param, function (success) {
    success.cover = tripleDes.deCode(success.cover)
    success.price = tripleDes.deCode(success.price)
    success.priceNum= tripleDes.deCode(success.priceNum)
    success.teacherHead = tripleDes.deCode(success.teacherHead)
    success.teacherName = tripleDes.deCode(success.teacherName)
    success.title = tripleDes.deCode(success.title)
    success.videoList.forEach(function(currentItem,index){
      currentItem.cover = tripleDes.deCode(currentItem.cover)
      currentItem.id = tripleDes.deCode(currentItem.id)
      currentItem.price = tripleDes.deCode(currentItem.price)
      currentItem.title = tripleDes.deCode(currentItem.title)
    })
    callBack(success)
  }, function (code, errMsg) {
    wx.showToast({
      title: errMsg,
      icon: ''
    })
    wx.navigateBack({
      
    })
  })
}

module.exports = {
  getGradeList: getGradeList,
  getPorjectTypeList: getPorjectTypeList,
  getProjectEditionList: getProjectEditionList,
  getCourseList: getCourseList,
  getDetail: getDetail,
}